package com.gasstation

import java.util.Date

class InventoryMidGrade {
	Date transactionOn
	double midGradeOpenGallons
	double midGradeOpenInvCost
	double midGradePurchasedGallons
	double midGradePurchasedCost
	double midGradeSaleGallons
	double midGradeCloseGallons
	double midGradeActualGallons
	double midGradeAvgCost
	double midGradeCost
	double midGradeVariance

	// Automatically updated by GORM
	Date dateCreated
	// Automatically updated by GORM
	Date lastUpdated
	static mapping = { sort transactionOn:"asc" }
	static constraints = { transactionOn unique: true }
	void calculateMidGradeCloseGallons(){
		midGradeCloseGallons = midGradeOpenGallons+midGradePurchasedGallons-midGradeSaleGallons
	}
	void calculateMidGradeAvgCost(){
		midGradeAvgCost = (midGradeOpenInvCost+midGradePurchasedCost)/(midGradeOpenGallons+midGradePurchasedGallons)
	}
	void calculateMidGradeCost(){
		midGradeCost = midGradeSaleGallons*midGradeAvgCost
	}
	void calculateMidGradeVariance(){
		midGradeVariance = midGradeActualGallons - midGradeCloseGallons
	}
}
